package com.foo;

import in.co.codedoc.cg.annotations.ExportedRPCMethod;
import in.co.codedoc.cg.annotations.ExportsRPCMethods;
import in.co.codedoc.cg.annotations.HasProperties;
import in.co.codedoc.cg.annotations.IsMappedToJSON;
import in.co.codedoc.cg.annotations.IsMappedToTable;
import in.co.codedoc.cg.annotations.Property;

@IsMappedToTable("bar")
@IsMappedToJSON
@HasProperties
({
	@Property(name="propOne",identity=true),
	@Property(name="propTwo",version=true),
	@Property(name="propThree",datatype=String.class)
})
@ExportsRPCMethods
public class Bar
	extends BarBase
{
	@ExportedRPCMethod(user="u1",name="BarCount")
	public static int CountBars()
	{
		return Find(null).size();
	}
	
	@ExportedRPCMethod(user="u1",roles="Role2,Role3")
	public static Bar CreateBar(String name)
	{
		Bar bar = new Bar();
		
		bar.SetPropThree(name);
		bar.Save();
		return bar;
	}
}
